package android.serialport.sample;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;


public class TemperatureActivity extends Activity {

    private static final String TAG = "TemperatureActivity";
    private TextView mInfoTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_temperature);
        mInfoTv = findViewById(R.id.object_tv);
        TemperatureManager.init();
        TemperatureManager.getInstance().registerListener(new TemperatureManager.TemperatureListener() {
            @Override
            public void onChange(double humanTemperature) {
                final String b = String.format("%.2f", humanTemperature);
                mInfoTv.post(new Runnable() {
                    @Override
                    public void run() {
                        mInfoTv.setText("  人体温度 ：" + b);
                    }
                });
            }
        });
    }
}
